<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title>订单查询</title>
    <c:set var="path" value="${pageContext.request.contextPath}"></c:set>
    <link rel="stylesheet" href="${path}/layui/css/layui.css">
    <link rel="stylesheet" href="/layui/css/formSelects-v4.css" media="all ">
    <script src="${path}/layui/layui.js"></script>
    <script src="${path}/js/jquery.min.js"></script>
</head>

<body>
<div id="plan" style="display: none">
    <table class="layui-table" lay-filter="planTable" id="planTable"></table>
</div>
    <h2>订单查看</h2>
    <hr>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">收货人:</label>
                <div class="layui-input-inline" style="width: 200px">
                    <input id="aaakehu" type="text" name="cusno" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-input-inline" style="width: 200px">
                    <button type="button" class="layui-btn" onclick="SearchData();"><i class="layui-icon layui-icon-search"></i>查询</button>
                </div>
            </div>
        </div>
    </form>
    <div class="layui-fluid">
        <table id="orderselectTable" lay-filter="orderselectTable"></table>
    </div>

    <script>
        layui.use(["table","form"],function () {
            var table=layui.table;
            //渲染表格
            table.render({
                elem:"#orderselectTable",
                url:"${path}/order/getchaxun",
                page:true,
                cols:[[
                    {field:'orderno',title:'订单编号'},
                    {field:'cusno',title:'收货人'},
                    {field:'price',title:'订单金额'},
                    {field:'tIME',title:'下单时间'},
                    {templet:'#state',title:'状态'},
                    {toolbar:'#barDemo',title:'操作'}

                ]]
            })

            //监听工具栏事件
            table.on('tool(orderselectTable)',function (obj) {
                var data=obj.data;
                var e=obj.event;
                switch (e) {
                    case "chakan":
                        console.log(data)
                        layer.open({
                            type: 1,
                            title: "详细信息",
                            skin: "layui-layer-molv",
                            anim: 0,
                            offset:"260px",
                            area: "800px",
                            content: $("#plan"),
                            btn: ['返回'],
                            success: function () {
                                console.log(data)
                                //  添加计划表格
                                table.render({
                                    elem: '#planTable'
                                    ,url:'${path}/order/xiangqing?Ordered='+data.cusno
                                    ,text: {none: '详细信息'}
                                    ,even: true
                                    ,page : true
                                    ,limit : 10
                                    ,toolbar: "#planTopDemo"
                                    ,cols: [[
                                        {field:'id', width:105, title: '商品ID'}
                                        ,{templet:'#names', title: '商品名称'}
                                        ,{field:'price', title: '商品单价'}
                                        ,{field:'fuzhu', title: '商品数量'}
                                    ]]
                                });
                            }
                        });
                        break;


                }

            })
        })
            function SearchData() {
                layui.table.reload("orderselectTable",{
                    page:{
                        curr:1
                    },
                    where:{
                            "cusno":$("#aaakehu").val()
                    }
                })
            }


        </script>

    <script type="text/html" id="custname">
        {{d.crmCustomers.custName}}
    </script>
    <script type="text/html" id="state">
        {{d.crmDictionaries.name}}
    </script>

    <script type="text/html" id="barDemo">
        <a href="javascript:void (0)" lay-event="chakan"><button class="layui-btn">查看</button></a>
    </script>
<script type="text/html" id="names">
    {{d.crmShopping.name}}
</script>

</body>
</html>
